<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
{{-- resources\views\components\form-subject.blade.php --}}
<form action="{{url('/subject')}}" method="get">
    Lib：<input type="text" name="lib" value="@php
    echo $_GET['lib']??'laravel';
    @endphp">laravel or maogai<br>
    Q：<input type="text" name="q">
    <input type="submit" value="提交">
</form>
@php
        $subject = $_GET['q'] ?? "无输入";
        $lib = $_GET['lib'] ?? 'laravel';
        // dump( DB::select('select * from user where id = ?', [1]) );
        // dump(DB::select("SELECT id,subject,`laravel`.key FROM `laravel` WHERE subject LIKE '%$subject%';"));
        $dan = DB::select("SELECT id,type,subject,`$lib`.key FROM `$lib` WHERE subject LIKE '%$subject%';");
        // dump($dan);
        echo '<table>';
        if ($lib == 'laravel') {
            foreach ($dan as $id => $dan2) {
                foreach ($dan2 as $id2 => $key) {
                    if ($id2 == 'key') {
                        echo "<b>$key</b>";echo "</table><hr><table>";
                    }else {
                        echo $key;echo '<br>';
                    }
                }
                echo " ";
            }
            echo '</table>';
        }else {
            foreach ($dan as $id => $dan2) {
                foreach ($dan2 as $id2 => $key) {
                    if ($id2 == 'key') {
                        echo "<b>$key</b>";echo "<hr>";
                    }else {
                        echo $key;echo '<br>';
                    }
                }
            }
        }
        @endphp
</body>
</html>